/*
* 包含n个由action触发去直接更新状态的方法的对象
* */
import {ADD_TODO, DEL_COMPLETE_TODOS, DEL_TODO, SELECT_ALL_TODOS,RECEIVE_TODOS} from "./mutationTypes";

export default {
    [ADD_TODO](state,{todo}){
        state.todos.unshift(todo)
    },
    [DEL_TODO](state,{index}){
        state.todos.splice(index,1)
    },
    [SELECT_ALL_TODOS](state,{isChecked}){
        state.todos.forEach(todo => todo.complete = isChecked)
    },
    [DEL_COMPLETE_TODOS](state){
        state.todos = state.todos.filter(todo => !todo.complete)
    },
    [RECEIVE_TODOS](state,{todos}){
        state.todos = todos;
    }
}